<template>
  <div>
    <div class="top-nav">
      <div class="left">
        <ul>
          <li><a href="">Weknow</a></li>
          <li><a href="">读书</a></li>
          <li><a href="">电影</a></li>
          <li><a href="">音乐</a></li>
          <li><a href="">同城</a></li>
          <li><a href="">小组</a></li>
          <li><a href="">阅读</a></li>
          <li><a href="">FM</a></li>
          <li><a href="">时间</a></li>
          <li><a href="">豆品</a></li>
        </ul>
      </div>
      <div class="right">
        <ul>
          <li><a href="">下载</a></li>
          <li><a href="">提醒</a></li>
          <li>
            <img :src="suburl1 + obj.touxiang" v-if="isimgshow" />
            <span class="userinfo" v-if="isspanshow"
              >{{ obj.email }}
              <div class="hidebox">
                <a href="">个人中心</a>
                <a href="" @click="outlogin">退出登录</a>
              </div>
            </span>
          </li>
          <li>
            <a @click="fn3" v-if="isloginshow" style="cursor: pointer">登录 </a>
          </li>
        </ul>
      </div>
    </div>

    <div class="wenav">
      <div class="nav-primary clearfix">
        <div class="nav-logo">
          <router-link :to="{path:'/ytx/square'}">Weknow广场</router-link>

        </div>
        <div class="nav-items">
          <ul>
            <li><router-link :to="{path: '/ytx/tcont'}" style="text-decoration: none;">原创</router-link>
            </li>
            <li ><router-link :to="{path: '/ytx/scont'}" style="text-decoration: none;">社区</router-link></li>
            <li ><router-link :to="{path: '/ytx/ncont'}" style="text-decoration: none;">最新</router-link></li>
            <li ><router-link :to="{path: '/ytx/hcont'}" style="text-decoration: none;">最热</router-link></li>
            <!-- <li ><router-link :to="{path: '/ytx/tcont'}" style="text-decoration: none;">生活</router-link></li>
            <li ><router-link :to="{path: '/ytx/tcont'}" style="text-decoration: none;">科技</router-link></li> -->
          </ul>
        </div>

        <div class="nav-search">
          <form
            id="form"
            action="https://www.douban.com/group/search"
            method="get"
          >
            <fieldset>
              <legend>搜索：</legend>

              <input type="hidden" name="cat" value="1019" />
              <label for="inp-query">帖子、话题</label>
              <div class="inp">
                <input
                  id="inp-query"
                  name="q"
                  size="22"
                  maxlength="60"
                  value=""
                />
              </div>
              <div class="inp-btn"><input type="submit" value="搜索" />搜索</div>
            </fieldset>
          </form>
        </div>
      </div>
    </div>
    <div id="box">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isimgshow: true,
      isspanshow: true,
      isloginshow: false,
      inputvalue: "",
      soureData: [],
      showData: [],
      isShowSearch: false,
      isControlShow: true,
      arr: [],
      obj: {},
    };
  },
  async mounted() {
    let res1 = await this.$axios("zuire");
    this.arr = res1.data;

    let res2 = await this.$axios("getuserinfo");
    if (res2.data.code == 4004) {
      this.isloginshow = true;
      this.isimgshow = false;
      this.isspanshow = false;
    } else if (res2.data.code == 2004) {
      this.isloginshow = false;
      this.isimgshow = true;
      this.isspanshow = true;
      this.obj = res2.data;
    }
  },
  methods: {
    fn3() {
      this.$router.push({ path: `/cll/login` });
    },
    async outlogin() {
      let res = await this.$axios("outlogin");
      if (res.data.code == 2001) {
        localStorage.removeItem("token");
      }
    },
  },
};
</script>

<style scoped lang="scss">
* {
  margin: 0;
  padding: 0;
}
#box {
  width: 1200px;
  margin-left: 150px;
}
.top-nav {
  width: 100%;
  height: 28px;
  background-color: #545652;
  display: flex;
  .left {
    width: 70%;
    ul {
      display: flex;
      list-style: none;
      li {
        width: 48px;
        height: 28px;
        line-height: 28px;
        display: flex;
        justify-content: center;
      }
    }
  }
  a {
    color: #d5d5d5;
    font-size: 12px;
    text-decoration: none;
  }
  .right {
    width: 30%;
    display: flex;
    ul {
      display: flex;
      list-style: none;
      li {
        width: 48px;
        height: 28px;
        line-height: 28px;
        display: flex;
        justify-content: center;
        position: relative;
        img {
          position: absolute;
          width: 25px;
          height: 25px;
          border-radius: 50%;
        }
        span {
          display: inline-block;
          position: absolute;
          font-size: 13px;
          left: 90px;
          top: -4px;
        }
      }
    }
    ul li .userinfo {
      display: inline-block;
      position: relative;
      text-align: center;
      cursor: pointer;
    }
    ul li .userinfo .hidebox {
      width: 200px;
      height: 100px;
      background-color: red;
      position: absolute;
      z-index: 10000;
      left: -85px;
      display: none;
    }
    ul li .userinfo:hover .hidebox {
      display: block;
    }
  }
}
.wenav {
  width: 100%;
  height: 100px;
  background-color: #f0f6f3;
  display: flex;
  font-size: 13px;
  justify-content: center;

  .nav-primary {
    width: 100%;
    display: flex;
    position: relative;
    justify-content: center;
    zoom: 1;
    right: 200px;
    .nav-logo {
      display: flex;
      height: 56px;
      width: 160px;
      position: relative;
      top: 30px;
      left: 10px;
      color: #09829e;
      a {
        font-size: 25px;
        font-weight: bold;
        text-decoration: none;
        cursor: pointer;
      }
    }
    .nav-items {
      height: 20px;
      width: 500px;
      display: flex;
      position: relative;
      top: 40px;
      left: 10px;
      ul {
        height: 30px;
        width: 100%;
        list-style-type: none;
        display: flex;
        justify-content: space-around;
        font-size: 16px;
        cursor: pointer;
        color: #037B82;
        router-link{
          text-decoration: none;
        }
      }
      li:hover{
        background-color: #037B82;
        color: white;
      }
    }
    .nav-search {
      position: absolute;
      right: 20px;
      top: 24px;
      width: 282px;
      overflow: hidden;
      zoom: 1;
      padding: 10px 0 15px 0;
      form {
        margin: 0;
        padding: 0;
        border: 0px;
        display: block;
        fieldset {
          border: none;
          padding: 0;
          margin: 0;
          position: static;
          legend {
            display: none;
            color: #666;
            padding: 0 5px;
          }
          input {
            appearance: none;
            border: none;
            background: transparent;
          }
          label {
            top: 11px;
            line-height: 28px;
            position: absolute;
            left: 11px;
            cursor: text;
            color: #bbb;
            width: auto;
            font-family: Tahoma;
            vertical-align: middle;
          }
          .inp {
            float: left;
            width: 278px;
            height: 28px;
            background: #fff;
            border: 1px solid #e1e9e1;
            text-align: left;
            border-radius: 0;
            cursor: text;
            input {
              margin: 0;
              width: 242px;
              height: 28px;
              background: #fff;
              text-align: left;
              padding-left: 10px;
            }
          }
          .inp-btn {
            position: absolute;
            left: auto;
            top: 10px;
            right: 0;
            width: 30px;
            height: 28px;
            border: 1px solid #e1e9e1;
            border-left: none;
            font-size: 0;
            overflow: hidden;
            zoom: 1;
            input {
              width: 30px;
              height: 28px;
              padding: 0;
              margin: 0;
              line-height: 100px;
              background:  url("./views/img/搜索.png") no-repeat 50% 50%;
              cursor: pointer;
            }
          }
        }
      }
    }
  }

  .clearfix:after {
    content: ".";
    display: block;
    height: 0;
    visibility: hidden;
    clear: both;
  }
}
</style>